package com.baidu.controller;

import com.baidu.entity.User;
import com.baidu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/***
 * 用户controller层实现类
 */

@Controller
public class UserController {
    @Autowired
    private UserService userService;
    /**
     * 查询所有用户信息
     */
    @RequestMapping("/FindAll")
    @ResponseBody
public List<User> getUserInfoAll(){
   List<User> users = userService.getUserInfoAll();
   if(users != null) {
       return users;
   }else {
       return null;
   }
}
     /**
       * 登录方法
      */
   @RequestMapping("/login")
   @ResponseBody
public User UserLogin(User user){
     //调用service层方法
       User user1=userService.UserLogin(user);
       //判断用户的返回值
       System.out.println(user1);
           return user1;
   }
    @RequestMapping(value="userAction_toLogin")
    public String userAction_toLogin(){
        return "forward:login.jsp";
    }


}
